import React, { useState, memo } from "react";
import { View } from '@tarojs/components'
import './index.scss'


function DataPicker(props) {

  const { dataList = [] } = props
  const [current, setCurrent] = useState(0)
  const changeDate = (value, index) => {
    setCurrent(index)
    props.changeCurrent(index)

  }
  return (
    <View className='picker-main'>
      {
        dataList.map((item, index) => {
          return (
            <View className={current == index ? 'isActive' : ''} key={item.value} onTap={() => changeDate(item.value, index)}>
              {item.label}
            </View>
          )
        })
      }

    </View >

  )
}

export default memo(DataPicker)
